home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 4.2 KB | 152 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: ButtonPart.cpp
- // Release Version: $ 1.0d1 $
- //
- // Author: Henri Lamiraux
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef _BUTTONPART_
- #include "ButtonPart.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWUTIL_H
- #include <FWUtil.h>
- #endif
-
- #ifndef FWPOINT_H
- #include <FWPoint.h>
- #endif
-
- #ifndef FWRECT_H
- #include <FWRect.h>
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _SHAPE_
- #include <Shape.h>
- #endif
-
- // ----- Macintosh Includes -----
-
- #ifndef mathRoutinesIncludes
- #include <math routines.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #pragma segment buttonpart
-
- //==============================================================================
- // •• class CButtonPart
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • CButtonPart::CButtonPart
- //------------------------------------------------------------------------------
-
- CButtonPart::CButtonPart()
- {
- }
-
- //------------------------------------------------------------------------------
- // • CButtonPart::~CButtonPart
- //------------------------------------------------------------------------------
-
- CButtonPart::~CButtonPart()
- {
- }
-
- //------------------------------------------------------------------------------
- // • CButtonPart::CreateControlHandle
- //------------------------------------------------------------------------------
-
- ControlHandle CButtonPart::CreateControlHandle(XMPPlatformWindow window, const FW_CRect& controlRect)
- {
- FW_SPlatformRect rect = controlRect;
- return ::NewControl(window, &rect, "\pOK", TRUE, 0, 0, 1, pushButProc, (long)this);
- }
-
- //----------------------------------------------------------------------------------------
- // • CButtonPart::GetContentPropertyValueType
- //----------------------------------------------------------------------------------------
-
- XMPValueType CButtonPart::GetContentPropertyValueType() const
- {
- return kSampleButtonKind;
- }
-
- //------------------------------------------------------------------------------
- // • CButtonPart::NewFrame
- //------------------------------------------------------------------------------
-
- FW_CFrame* CButtonPart::NewFrame(XMPFrame* xmpFrame, XMPTypeToken presentation)
- {
- FW_UNUSED(presentation);
-
- CButtonFrame *frame = new CButtonFrame;
- frame->InitButtonFrame(xmpFrame, this);
- return frame;
- }
-
- //==============================================================================
- // •• class CButtonFrame
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • CButtonFrame::CButtonFrame
- //------------------------------------------------------------------------------
-
- CButtonFrame::CButtonFrame()
- {
- }
-
- //------------------------------------------------------------------------------
- // • CButtonFrame::InitButtonFrame
- //------------------------------------------------------------------------------
-
- void CButtonFrame::InitButtonFrame(XMPFrame* frame, FW_CPart* part)
- {
- InitCtlMgrFrame(frame, part);
- }
-
- //------------------------------------------------------------------------------
- // • CButtonFrame::~CButtonFrame
- //------------------------------------------------------------------------------
-
- CButtonFrame::~CButtonFrame()
- {
- }
-
- //------------------------------------------------------------------------------
- // • CButtonFrame::UpdateUsedShape
- //------------------------------------------------------------------------------
-
- void CButtonFrame::UpdateUsedShape()
- {
- FW_CPoint controlSize;
- ((CButtonPart*)GetPart())->GetControlSize(controlSize);
- FW_SPlatformRect controlRect;
- ::SetRect(&controlRect, 0, 0, FixedToInt(controlSize.x), FixedToInt(controlSize.y));
-
- FW_PlatformRegion rgn = ::NewRgn();
- ::InsetRect(&controlRect, -1, -1);
- ::OpenRgn();
- ::FrameRoundRect(&controlRect, 16, 16);
- ::CloseRgn(rgn);
-
- XMPShape* scratch = ::NewXMPShape(rgn);
- scratch->Intersect(GetXMPFrame()->GetFrameShape());
- GetXMPFrame()->ChangeUsedShape(scratch);
- }
-
-